package com.learn.bean;

import com.learn.service.UserService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@Component
public class IUser implements BeanFactoryAware {

	@Autowired
	private UserService userService;

	private BeanFactory beanFactory;


	public void  test(){
		System.out.println(userService);
	}

	public void  test2(){
		UserService userService1 = beanFactory.getBean(UserService.class);
		System.out.println(userService1);
	}

	@Override
	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
		this.beanFactory = beanFactory;
	}
}
